//
//  FIndCarDetailVC.m
//  B段项目
//
//  Created by dllo on 15/9/29.
//  Copyright (c) 2015年 昶博. All rights reserved.
//

#import "FIndCarDetailVC.h"
#import "PrefixHeader.pch"
@interface FIndCarDetailVC () <UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, assign) NSInteger i;

@end

@implementation FIndCarDetailVC

- (void)viewWillAppear:(BOOL)animated
{
    SelfNavBar.hidden = YES;
    SelfTabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
#pragma mark --详情页返回键
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.frame = CGRectMake(ScreenWidth * 5 / 375, ScreenHeight * 30 / 667, ScreenWidth * 60 / 375, ScreenHeight * 45 / 667);
    backButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [backButton setTitle:@"返回" forState:UIControlStateNormal];
    [backButton setTitleColor:RGB(22, 188, 180) forState:UIControlStateNormal];
    [self.view addSubview:backButton];
    [backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self webViewSubviews];
}

- (void)webViewSubviews
{
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, ScreenHeight * 70 / 667, ScreenWidth , ScreenHeight - ScreenHeight * 70 / 667 )];
    self.webView.scrollView.bounces = NO;
    self.webView.delegate = self;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webLink]];
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    self.i++;
    [self hideWaiting];
    SelfTabBar.hidden = YES;
}

//消除滚动轮指示器
-(void)hideWaiting
{
    //[[self.view viewWithTag:9999] removeFromSuperview];
    [[self.view viewWithTag:9998] removeFromSuperview];
    
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if (self.i <= 0) {
        return YES;
    }else
        return NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark --返回按键方法
- (void)backButtonClicked:(UIButton *)button
{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
 
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
